package com.paperlessmedical.interceptor;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
@SuppressWarnings("serial")
public class CashierLoginCheck extends AbstractInterceptor{
	@Override
	@SuppressWarnings("unchecked")
	public String intercept(ActionInvocation ai) throws Exception {
		// TODO Auto-generated method stub
		Map session = ai.getInvocationContext().getSession() ;
		String cashierLoginName = (String)session.get("cashierLoginName") ;
		HttpServletRequest request = ServletActionContext.getRequest() ;
		String currentURL = request.getRequestedSessionId() ;
		if(currentURL.contains("drug")){
			if(!(cashierLoginName == null || "".equals(cashierLoginName.trim()))){
				return ai.invoke() ;
			}else{
				return "cashierLogin" ;
			}
		}else{
			return ai.invoke() ;
		}
		
	}
}
